Description: ReactJS provides a bunch of methods that are executed during different stages of components life. Those
are called lifecycle methods. Lifecycle methods are only available for class based components. For functional
components react provides hooks. Let’s go through this diagram.
Horizontally it is split into three main stages:
Mounting
Updating
Unmounting
Mounting
This is first stage each component goes through. During this stage component gets created and then mounted to the DOM.
First method that is being executed during this stage is constructor.
Updating
Next big stage is is updating. Methods of this stage get called every time props or state of the component get changed
or forceUpdate() gets called.
Unmounting
Last stage is unmounting and it has only one method - componentWillUnmount.This method is being called right before the
component is being removed from the DOM.It is a good place to perfom the cleanup and remove your event listeners or
timers that you might have added in componentDidMount.